<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="zh-CN">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>后台页面-上海市嘉定区人民法院</title>
		<style>
body {
	background: url(images/main_bg_03.png) repeat;
}

.list-content {
	width: 850px;
	height: 550px;
	font-size: 12px;
	text-align: left;
	border: 2px solid #92b0c6;
	color: #666;
	display: inline-block;
}

.list_page {
	margin-right: 10px;
	width: 842px;
	line-height: 18px;
	font-size: 12px;
	text-align: right;
	color: #666;
	display: inline;
	float: left;
}

.list_page_text {
	color: #146185;
}

.btn02 {
	width: 78px;
	height: 24px;
	background: url(images/btn_list01.png) no-repeat;
	border: none;
	color: #003366;
	cursor: pointer;
	display: inline;
}

.btn03 {
	width: 78px;
	height: 24px;
	background: url(images/btn_list04.png) no-repeat;
	border: none;
	color: #990000;
	cursor: pointer;
	font-weight: bold;
	display: inline;
}

.edit-content {
	width: 850px;
	height: 550px;
	font-size: 12px;
	text-align: left;
	border: 2px solid #92b0c6;
	color: #666;
	display: inline-block;
}

.input01 {
	width: 110px;
	height: 20px;
	border: 1px solid #a1a1a1;
}

a {
	text-decoration: none;
	color: #666;
}

a:hover {
	color: #FF9900;
}
</style>

		<link rel="stylesheet" href="themes/default/default.css" />
		<link rel="stylesheet" href="plugins/code/prettify.css" />
		<script charset="utf-8" src="kindeditor.js"></script>
		<script charset="utf-8" src="lang/zh_CN.js"></script>
		<script charset="utf-8" src="plugins/code/prettify.js"></script>
		<script type="text/javascript" src="web/js/jquery-1.7.1.min.js"></script>
		<script type="text/javascript">
		KindEditor.ready(function(K) {
			var editor = K.create('textarea[name="content"]', {
				cssPath : 'plugins/code/prettify.css',
				uploadJson : 'jsp/upload_json.jsp',
				fileManagerJson : 'jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K('#J_selectImage').click(function() {
						editor.loadPlugin('multiimage', function() {
							editor.plugin.multiImageDialog({
								clickFn : function(urlList) {
									var div = K('#J_imageView');
									div.html('');
									K.each(urlList, function(i, data) {
										div.append('<img src="' + data.url + '">');
									});
									editor.hideDialog();
								}
							});
						});
					});
					K('#image3').click(function() {
						editor.loadPlugin('image', function() {
							editor.plugin.imageDialog({
								showRemote : false,
								imageUrl : K('#url3').val(),
								clickFn : function(url, title, width, height, border, align) {
									K('#url3').val(url);
									editor.hideDialog();
								}
							});
						});
					});
					K('input[name=btnSubmitInfo]').click(function(e) {
						var checks=document.getElementsByName("articleClazz");
						if(checks.length==0){return false;}
						if($("#url3").val()==null||$("#url3").val()==''){
						alert("缩略图不能为空,请重新填写!");
						return false;}
						var chkValue = getChk();
						if (confirm("是否确认创建"))  
							{  
								$.ajax({
										type: "POST",
										url: "insertArticle.action?articleClazz="+chkValue+"&picturePath="+$("#url3").val(),
										dateType: "json",
										data: {"title": $("#title").val(),"author": $("#author").val(), "content": editor.html(),"shortContent": $("#shortContent").val(),"editor": $("#editor").val(),"source": $("#source").val(),"extraTitle": $("#extTitle").val()},
										success: function(returnedData){
												
												var json = eval( "("+returnedData+")" );
												alert(json.confirmIns);
												window.location="Articlelist.action?classId="+json.classID;
										}
									});
							}  
							else  
							{ 
							return false;
							};	
					});
					
				}
			});
			
			prettyPrint();
		});
		function getFileSize(filePath)    
		{    
	   	 var image=new Image();    
	   	image.dynsrc=filePath;    
	    alert(image.fileSize);    
	 	}  
			
		function getChk()
		{
			var chks=document.getElementsByName("articleClazz");
			var idString = "";
			for(var i = 0;i < chks.length; i++)
			{
				if(chks[i].checked)
				{
					idString+=chks[i].value+",";
				}
			}
			return idString;
		}
		function selectExtraTitle()
		{
			var st = document.getElementById("extraTitle");
			var mytr = document.getElementById("titleTR");
			if(st.checked)
			{
				mytr.style.visibility="visible";
			}else{
				mytr.style.visibility="hidden";
			}
		}
	</script>
	</head>
	<body>

		<div class="edit-content">
			<table width="800" cellSpacing=0>

				<s:set name="count" value="1" />
				<s:set name="size" value="detailPage.showArticleClass.size()" />
				<tr>
					<s:iterator value="detailPage.showArticleClass" var="val"
						status="status">
						<s:if test="(#status.count-1) %10 == 0">
				</tr>
				<tr>
					<td width="84">
						<s:if test="#val.classID==detailPage.classID">
							<input type="checkbox" name="articleClazz"
								value="<s:property value='#val.classID'/>" checked="true" />
							<s:property value="#val.className" />
						</s:if>
						<s:else>
							<input type="checkbox" name="articleClazz"
								value="<s:property value='#val.classID'/>" />
							<s:property value="#val.className" />
						</s:else>
					</td>
					</s:if>
					<s:else>
						<td width="84">
							<s:if test="#val.classID==detailPage.classID">
								<input type="checkbox" name="articleClazz"
									value="<s:property value='#val.classID'/>" checked="true" />
								<s:property value="#val.className" />
							</s:if>
							<s:else>
								<input type="checkbox" name="articleClazz"
									value="<s:property value='#val.classID'/>" />
								<s:property value="#val.className" />
							</s:else>
						</td>
					</s:else>
					<s:set name="count" value="#count+1" />
					</s:iterator>
				</tr>
				<tr>
					<td colspan="10">
						&nbsp;
					</td>
				</tr>
				<tr>
					<td colspan="3">
						标题:&nbsp;
						<input type="text" id="title" name="title" class="input01" />
						<input type="checkbox" id="extraTitle" name="extraTitle"  onclick="selectExtraTitle()"/>
					</td>
					<td colspan="3">
						作者:&nbsp;
						<input type="text" id="author" name="author" class="input01" />
					</td>
					<td colspan="4">
						&nbsp;
					</td>
				</tr>
				<tr>
					<td colspan="3">
						来源:&nbsp;
						<input type="text" id="source" name="source" class="input01" />
					</td>
					<td colspan="3">
						编辑:&nbsp;
						<input type="text" id="editor" name="editor" class="input01" />
					</td>
					<s:if test="208==detailPage.classID">
					<td colspan="2">
						缩略图:&nbsp;
						<input type="text" id="url3" name="url3" class="input01" />
					</td>
					<td>
						<input type="button" name="image3" id="image3" value="选择图片"
							class="btn02" />
					</td>
					</s:if>
					
				</tr>
				<tr>
					<td colspan="10">
						<div id="J_imageView"></div>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td colspan="10" align="left" valign="top">
						摘要:
						<textarea id="shortContent" cols="100" rows="2"></textarea>
					</td>
				</tr>
				<tr id="titleTR" style="visibility:hidden">
					<td colspan="10" align="left" valign="top">
						标题重写:
						<textarea id="extTitle" cols="100" rows="2"></textarea>
					</td>
				</tr>
				<tr>
					<td colspan="10" align="left" valign="top">
						内容:
						<textarea id="content" name="content" cols="100" rows="6"
							style="width: 820px; height: 200px; visibility: hidden;"></textarea>
					</td>
				</tr>
				<tr>
					<td colspan="10">
						<input type="button" name="btnSubmitInfo" id="btnSubmitInfo"
							value="提交内容" class="btn03" />
					</td>
					<td colspan="10">
						<input type="button" name="back" id="back"
							value="返回" class="btn03" onclick="history.go(-1)"/>
					</td>
				</tr>
				<tr>
					<td colspan="10">
						&nbsp;
					</td>
				</tr>
			</table>
		</div>
	</body>
</html>





